package net.xdclass.service.impl;

import cn.hutool.core.bean.BeanUtil;
import net.xdclass.interceptor.LoginInterceptor;
import net.xdclass.manager.DomainManager;
import net.xdclass.model.DomainDO;
import net.xdclass.mapper.DomainMapper;
import net.xdclass.model.vo.DomainVO;
import net.xdclass.service.IDomainService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hr
 * @since 2025-08-05
 */
@Service
public class DomainServiceImpl extends ServiceImpl<DomainMapper, DomainDO> implements IDomainService {
    @Autowired
    private DomainManager domainManager;

    @Override
    public List<DomainVO> listAll() {
        Long accountNo = LoginInterceptor.threadLocal.get().getAccountNo();
        List<DomainDO> customDomainList = domainManager.listCustomDomain(accountNo);
        List<DomainDO> officialDomainList = domainManager.listOfficialDomain();
        customDomainList.addAll(officialDomainList);
        List<DomainVO> domainVOList = BeanUtil.copyToList(customDomainList, DomainVO.class);
        return domainVOList;
    }
}
